package org.calrissian.restdoclet.model.type.property;

import com.sun.javadoc.FieldDoc;
import com.sun.javadoc.RootDoc;
import com.sun.javadoc.Type;
import org.calrissian.restdoclet.model.Model;
import org.calrissian.restdoclet.model.ModelProperty;
import org.calrissian.restdoclet.model.type.ParamTypeInfos;
import org.calrissian.restdoclet.util.TypeUtils;

import java.util.Map;

/**
 * Created by admin on 2017/9/3.
 */
public abstract class ModelPropertyGenerator {

    public abstract boolean belongToThisGenerator(Type fieldType, Type ownerType);

    public abstract ModelProperty generate(Type fieldType, FieldDoc fieldDoc, Type ownerType, Map<String, Model> result, RootDoc rootDoc, ParamTypeInfos paramTypeInfos);

    protected ModelProperty getBaseModelProperty(Type fieldType, FieldDoc fieldDoc) {
        ModelProperty modelProperty = new ModelProperty();
        modelProperty.setDescription(fieldDoc.commentText());
        modelProperty.setType(TypeUtils.dataType(fieldType));
        return modelProperty;
    }
}
